package com.kyb.cms.config;

import com.kyb.cms.util.oss.ResourceApiConfig;
import lombok.extern.slf4j.Slf4j;
import org.armada.galileo.common.util.SpringConfig;
import org.armada.galileo.rainbow_gate.transfer.discovery.LocalServerAddressUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.support.FormattingConversionServiceFactoryBean;

/**
 * nova 系列中间件引用
 *
 * @author xiaobo
 * @date 2021/11/1 6:46 下午
 */
@Configuration
@Slf4j
public class CmsMiniwebxConfig {

    /**
     * uri sevlet容器相对路径
     */
    private String contextPath = "cms-api";

    private String modulePath = "com.kyb.cms.module";

    @Autowired
    private ApplicationContext applicationContext;

    static {
        System.setProperty("localIp", LocalServerAddressUtil.getLocalServerIp());
    }

    @Bean
    public FormattingConversionServiceFactoryBean initMiniwebxConversion() {
        return SuperMiniwebxConfig.initMiniwebxConversion();
    }

    @Bean
    public ServletRegistrationBean initMiniwebx() {
        return SuperMiniwebxConfig.initMiniwebx(applicationContext, contextPath, modulePath);
    }



}
